# eric7.Testing.Interfaces.UnittestRunner

Module implementing the test runner script for the 'unittest' framework.

### Global Attributes

command
versions

### Classes

EricTestResult | Class implementing a TestResult derivative to send the data via a network connection.

### Functions

_assembleTestCasesList | Protected function to assemble a list of test cases included in a test suite.
runtest | Function to run and/or discover the tests.

## EricTestResult

Class implementing a TestResult derivative to send the data via a network connection.

### Derived from

unittest.TestResult

### Class Attributes

None

### Class Methods

None

### Methods

EricTestResult | Constructor
addError | Public method called if a test errored.
addExpectedFailure | Public method called if a test failed expected.
addFailure | Public method called if a test failed.
addSkip | Public method called if a test was skipped.
addSubTest | Public method called for each subtest to record its result.
addUnexpectedSuccess | Public method called if a test succeeded expectedly.
startTest | Public method called at the start of a test.
startTestRun | Public method called once before any tests are executed.
stopTest | Public method called at the end of a test.
stopTestRun | Public method called once after all tests are executed.

### Static Methods

None

#### EricTestResult (Constructor)

EricTestResult(writer, failfast)

Constructor

writer (EricJsonWriter)
  reference to the object to write the results to
failfast (bool)
  flag indicating to stop at the first error

#### EricTestResult.addError

addError(test, err)

Public method called if a test errored.

test (TestCase)
  reference to the test object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addExpectedFailure

addExpectedFailure(test, err)

Public method called if a test failed expected.

test (TestCase)
  reference to the test object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addFailure

addFailure(test, err)

Public method called if a test failed.

test (TestCase)
  reference to the test object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addSkip

addSkip(test, reason)

Public method called if a test was skipped.

test (TestCase)
  reference to the test object
reason (str)
  reason for skipping the test

#### EricTestResult.addSubTest

addSubTest(test, subtest, err)

Public method called for each subtest to record its result.

test (TestCase)
  reference to the test object
subtest (TestCase)
  reference to the subtest object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addUnexpectedSuccess

addUnexpectedSuccess(test)

Public method called if a test succeeded expectedly.

test (TestCase)
  reference to the test object

#### EricTestResult.startTest

startTest(test)

Public method called at the start of a test.

test (TestCase)
  reference to the test object

#### EricTestResult.startTestRun

startTestRun()

Public method called once before any tests are executed.

#### EricTestResult.stopTest

stopTest(test)

Public method called at the end of a test.

test (TestCase)
  reference to the test object

#### EricTestResult.stopTestRun

stopTestRun()

Public method called once after all tests are executed.

Up

## _assembleTestCasesList

_assembleTestCasesList(suite, start)

Protected function to assemble a list of test cases included in a test suite.

suite (unittest.TestSuite)
  test suite to be inspected
start (str)
  name of directory discovery was started at

Return:
  list of tuples containing the test case ID, the string representation, a short description and the path of the test file name

Return Type:
  list of tuples of (str, str, str, str)

Up

## runtest

runtest(argv, discoverOnly=False)

Function to run and/or discover the tests.

argv (list of str)
  list of command line parameters.
discoverOnly (bool (optional))
  flag indicating to just discover the available test cases (defaults to False)

Up